﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoreBDS;
using System.Text;

namespace BatDongSan.Modules
{
    public partial class Uc_Project : System.Web.UI.UserControl
    {
        int _idField;
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        public void LoadProject(int FieldId)
        {
            try
            {
                _idField = FieldId;
                lbTitle.Text = FieldOfActionBll.GetName(_idField, Utility.strConnect).ToUpper();
                List<VG_Project> list = ProjectBll.GetList(_idField, Utility.strConnect);
                rptProject.DataSource = list;
                rptProject.DataBind();
            }
            catch { }
        }
        protected void rptProject_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                    VG_Project info = (VG_Project)e.Item.DataItem;
                    Literal ltrImg = (Literal)e.Item.FindControl("ltrImg");
                    //hplImg.ImageUrl = "~/Images/Project/" + info.Img;
                    //hplImg.ToolTip = info.Name;
                    //hplImg.NavigateUrl = string.Format("~/ProjectDetail.aspx?id={0}", info.ProjectId);

                    ltrImg.Text = string.Format("<img src=\"/Images/Project/{0}\" width=\"120px\" height=\"82px\" />", info.Img);

                    Literal ltrInfo = (Literal)e.Item.FindControl("ltrInfo");
                    StringBuilder query = new StringBuilder();
                    query.AppendLine("<span><b>Địa chỉ:</b> " + info.Address + "</span>");
                    query.AppendLine("<span><b>Điện thoại:</b> " + info.Phone + " | <b>Fax:</b> " + info.Fax + "</span>");
                    query.AppendLine("<span><b>Website:</b> " + info.Website + "</span>");
                    query.AppendLine("<span><b>Email:</b> " + info.Email + "</span>");
                    query.AppendLine("<span><b>Thông tin dự án:</b> " + info.Note + "</span>");
                    ltrInfo.Text = query.ToString();

                    HyperLink hplName = (HyperLink)e.Item.FindControl("hplName");
                    hplName.NavigateUrl = string.Format("~/ProjectDetail.aspx?id={0}", info.ProjectId);
                    hplName.Text = info.Name;

                    
                }
            }
            catch { }
        }
    }
}